//
//  YQForumHeaderView.m
//  iyuanqi
//
//  Created by czl on 2017/7/27.
//  Copyright © 2017年 czl. All rights reserved.
//

#import "YQForumHeaderView.h"
#import "SDCycleScrollView.h"

@interface YQForumHeaderView ()
<SDCycleScrollViewDelegate>

@property(nonatomic,strong)SDCycleScrollView* bannerView;

@end

@implementation YQForumHeaderView

+ (NSString *)headerViewIdentifier {
    return @"YQForumHeaderView";
}

+ (instancetype)headerViewWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
    YQForumHeaderView *headerView = (YQForumHeaderView*)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[YQForumHeaderView headerViewIdentifier] forIndexPath:indexPath];
    return headerView;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        UILabel* label1 = [UILabel new];
        label1.textAlignment = NSTextAlignmentCenter;
        label1.text = @"爱厦门.爱生活.爱缘起";
        label1.font = [UIFont systemFontOfSize:16];
        [self addSubview:label1];
        [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.top.mas_equalTo(10);
        }];
        
        [self addSubview:self.bannerView];
        [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.mas_equalTo(self);
            make.top.mas_equalTo(label1.mas_bottom).offset(5);
        }];
    }
    return self;
}

- (void)setImageUrls:(NSArray*)urls {
    self.bannerView.autoScroll = YES;
    self.bannerView.imageURLStringsGroup = urls;
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    
}

- (SDCycleScrollView*)bannerView {
    if (!_bannerView) {
        _bannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:@"loadimage"]];
        _bannerView.autoScrollTimeInterval = 4;
        _bannerView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
        _bannerView.showPageControl = YES;
        _bannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
        _bannerView.pageDotColor = [UIColor whiteColor];
        _bannerView.currentPageDotColor = [UIColor blueColor];
        _bannerView.autoScroll = YES;
    }
    return _bannerView;
}

@end
